package com.itheima.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;

import javax.sql.DataSource;
import java.awt.dnd.DropTarget;

@PropertySource("classpath:jdbc.properties")
public class JdbcConfig {
@Value("jdbc:mysql://localhost:3306/cloud_book")
    private String url;
@Value("root")
    private String username;
@Value("root")
    private String password;
@Value("com.mysql.jdbc.Driver")
    private String driverClassName;
@Bean
    public DataSource DataSource(){
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setDriverClassName(driverClassName);
    dataSource.setUrl(url);
    dataSource.setUsername(username);
    dataSource.setPassword(password);
    return dataSource;
}
}
